package Base.Block;


/*
 * @author 枫城
 * @createTime 2022/9/8 11:02
 * @desc 静态代码块 vs 非静态代码块
 */
public class BlockTest {
    public static void main(String[] args) {
       String desc =  Block.desc;
        final Block block = new Block();
        final Block block2 = new Block();

    }
}

class Block{
    String name;
    int age;
    static  String desc = "花海";

    public Block() {
    }


    public Block(String name, int age) {
        this.name = name;
        this.age = age;
    }

    // static 代码块
    static {
        System.out.println("静态代码块");
    }

    // 非静态代码块
    {
        System.out.println("非静态代码块");
    }

    @Override
    public String toString() {
        return "Block{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
